package JunitTests;

import static org.junit.Assert.*;

import java.util.Arrays;

import objectClasses.Draft;
import objectClasses.Entry;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class DraftTests {

	private static Draft test;
	private Draft test2;
	@Before
	// Will be performed before each test.
	public void testSetup()
	{
		test = new Draft();
		test2 = new Draft();
		System.out.println("Setup for Draft tests complete.");
	}

	@Test
	public void test() {	
		assertTrue("Treading Arrays are not equal ",Arrays.equals(test.getThreadingArray(), 
				test2.getThreadingArray()));
		assertTrue("Treadling Arrays are not equal",Arrays.equals(test.getTreadlingArray(), 
				test2.getTreadlingArray()));
		assertTrue("Color Arrays are not equal",Arrays.equals(test.getThreadingColorArray(),
				test2.getThreadingColorArray()));
		assertTrue("TieupArray Arrays are not equal",Arrays.deepEquals(test.getTieupArray(),
				test2.getTieupArray()));
		assertTrue("Harness are not equal",test.getHarness(0)==test2.getHarness(0));
		try{
			assertTrue("100 should be out of bounds",test.getHarness(100)==test2.getHarness(100));
		}
		catch(IndexOutOfBoundsException e){
			System.out.println("Input given to draft.Harness "+ e.getMessage()+ 
					" threw IndexOutOfboundsException as expected");
		}
		assertTrue("Tieup test1 and test2 should be equal!",test.getTieup(0, 0)==
				test2.getTieup(0, 0));
		try{
			assertTrue("Tieup 100 should not be allowed exception should throw",
					test.getTieup(100, 100)==test2.getTieup(100, 100));
		}
		catch(IndexOutOfBoundsException e){
			System.out.println("Input given to draft.getTieup "+ e.getMessage()+ 
					" threw IndexOutOfboundsException as expected");
		}
		
		test.setHarness(0, 0);
		test2.setHarness(0, 0);
		assertTrue("Harnesses should be equal", test.getHarness(0)==test2.getHarness(0));
		
		test.setHarness(2, 2);
		test2.setHarness(2, 2);
		assertTrue(test.getHarness(2)==test2.getHarness(2));
	
		assertEquals(test.getPedal(0),test2.getPedal(0));
		assertNotSame(test.toString(),test2.toString());
		try{
		test.setTreadingColor(null, -1);
		}
		catch(IndexOutOfBoundsException e){
			System.out.println(e.getMessage()+ " Threw out of index exception as expected");
		}	

	}
	@After
	// Will be performed after each test.
	public void testComplete()
	{
		System.out.println("Draft tests complete");
	}
}
